import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from "@/layout"

export const constantRoutes = [
  { path: '/404', component: () => import('@/components/routerError/404'), hidden: true },
  { path: '/401', component: () => import('@/components/routerError/401'), hidden: true },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    hidden: true,
    meta: {
      title: '登录',
      icon: 'dashboard'
    }
  },
  // {
  //   path: "/",
  //   component: Layout,
  //   redirect: { name: 'home' },
  //   hidden: true,
  //   children: []
  // },
]
const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export default router

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
